jQuery(document).ready(function() {
	var phonename = $(".catalog-product-view .carousel.two h2").height();
	if(phonename > 40) {
		jQuery(".social-sharing").css("margin-top","-5px");
		//console.log("80px");
	}
	
	jQuery('#getgadget2').click(function() {
		document.cookie="gadget=" + jQuery('#phone_Name').text() + "; path=/"; 
		document.cookie="price=" + jQuery('#price').text() + "; path=/"; 
	});
	
	     var maitainumbercompare = getCookie("maitainumbercompare");	
		 
		if(maitainumbercompare=="2"){	 
		jQuery(".compare-sku").addClass("compare-sku-full");
		jQuery(".compare-sku-full").removeClass("compare-sku");
	     }  
	
	jQuery('.compare-sku').click(function(){
	     
	     var sku = jQuery(".compare-sku").attr('id');
	     var maitainumbercompare = getCookie("maitainumbercompare");

	     if(maitainumbercompare=="" || maitainumbercompare=="0") {
		document.cookie="maitainumbercompare=" + "1" + "; path=/";
		document.cookie="maitaicompare1=" + sku + "; path=/";
		window.location=baseurl + "compare";
	     }
		 else{

	     if(maitainumbercompare=="1") {
		 //alert("1");
		var maitaicompare1 = getCookie("maitaicompare1");
		if(maitaicompare1 != sku){
		  document.cookie="maitainumbercompare=" + "2" + "; path=/";
		  document.cookie="maitaicompare2=" + sku + "; path=/";
		  window.location=baseurl + "compare";
		}
		else
		  //alert("The product is already in comparison list.");
		  window.location=baseurl + "compare";
	     }
	     /*
	     if(maitainumbercompare=="2"){	 
		 alert("2");
		var maitaicompare1 = getCookie("maitaicompare1");
		var maitaicompare2 = getCookie("maitaicompare2");
		if(maitaicompare1 != sku || maitaicompare2 != sku)
		   alert("The comparison list is full.");
		else
	       //alert("The product is already in comparison list.");
		   window.location=baseurl + "compare";
	     }   */		 
        }
		 
		  
	});
	
	jQuery('.compare-sku-full').click(function(){
		alert("The comparison list is full.");
	});
	
	jQuery('#getgadget').click(function(){
		document.cookie="imgsrc=" + jQuery("#spec-img").attr('src') + "; path=/";	
		document.cookie="current_pos=" + "2" + "; path=/";
	});
	
	if(/specification/.test(self.location.href)){
	   var mode = getCookie("mode");
       if(mode=="edit"){
		 jQuery('#getgadget2').text("Save");
       }
    }
	

});


function getCookie(cname)
{
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) 
  {
  var c = ca[i].replace(/\s/g, "");
  if (c.indexOf(name)==0) return c.substring(name.length,c.length);
  }
return "";
}